import request from '@/axios'
import Cookies from 'js-cookie'

// 购物车列表
export const cartList = (params: any) => {
  params.token = Cookies.get('user_token')
  return request.get({ url: '/cart/pageListWithProductInfo', params })
}

// 加购
export const addCart = (data: any) => {
  data.token = Cookies.get('user_token')
  return request.post({ url: '/cart/add', data })
}
// 更新购物车
export const updateCart = (data: any) => {
  data.token = Cookies.get('user_token')
  return request.post({ url: '/cart/update/' + data.cartId, data })
}
//删除购物车
export const deleteCart = (cartId: number) => {
  const token = Cookies.get('user_token')
  return request.post({ url: `/cart/delete/${cartId}?token=${token}` })
}

//批量删除购物车
export const batchDeleteCart = (data: any) => {
  data.token = Cookies.get('user_token')
  return request.post({ url: '/cart/delete/batch', data })
}
